#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   20:54
# Author     : Y4
# Site       : 
# File       : 06 面向对象-继承has a.py
# Software   : PyCharm
'''
类的属性 是 其他类

Student 拥有 Computer 和 Book 类
'''


class Computer:
    def __init__(self, brand, color):
        self.brand = brand
        self.color = color

    def online(self):
        print("正在使用电脑上网")

    def __str__(self):
        return '{}---{}'.format(self.brand, self.color)


class Book:
    def __init__(self, name, brand, color):
        self.name = name
        self.brand = brand
        self.color = color

    def __str__(self):
        return '{}---{}---{}'.format(self.name, self.brand, self.color)


class Student:
    def __init__(self, name, computer, book):
        self.name = name
        self.computer = computer
        self.books = []
        self.books.append(book)

    # 借书
    def borrow_book(self, book):
        self.books.append(book)

    # 显示借的书
    def show_book(self):
        for i in self.books:
            print(i)


computer = Computer('苹果', '深空灰')
print(computer)

book = Book('盗墓笔记', '南派三叔', 10)
print(book)

s1 = Student('张三', computer, book)
s1.borrow_book(book)
s1.show_book()
